package cn.dogeye.common.protocol;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private int code;
    private String msg;
    private Object data;

    public static Result succ(Object data) {
        return succ(HttpStatus.OK.value(), "操作成功", data);
    }

    public static Result succ(String msg,Object data) {
        return succ(HttpStatus.OK.value(), msg, data);
    }

    public static Result succ(int code, String msg, Object data) {
        return new Result(code,msg,data);
    }
    public static Result fail(int code, String msg, Object data) {
        return new Result(code,msg,data);
    }
    public static Result fail(String msg) {
        return succ(HttpStatus.BAD_REQUEST.value(), msg, null);
    }
}
